package com.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.Toast;

import com.bigkoo.pickerview.listener.OnOptionsSelectListener;
import com.bigkoo.pickerview.view.OptionsPickerView;
import com.example.apple.ddhr_new.R;
import com.example.apple.ddhr_new.activity.widget.Dialog;
import com.example.apple.ddhr_new.utils.ToastUtil;
import com.example.lzbase.BaseViewModelActivity;

import org.apache.commons.lang3.StringUtils;

import java.util.ArrayList;

import butterknife.BindView;
import butterknife.OnClick;

public class JiaBanActivity extends BaseViewModelActivity {
    @BindView(R.id.tv_jiabanshijian)
    EditText tvJiabanshijian;
    @BindView(R.id.l_jiabanshijian)
    LinearLayout lJiabanshijian;

    @Override
    protected int titleText() {
        return R.string.jiaban;
    }

    @Override
    protected int getLayoutId() {
        return R.layout.layout_dakajiaban;

    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

    }

    @OnClick(R.id.l_jiabanshijian)
    public void onClick() {

        ArrayList<String> item1 = new ArrayList<>();

        item1.add("白班");
        item1.add("夜班");
        item1.add("中班");
        item1.add("白班加");
        OptionsPickerView optionsPickerView = Dialog.popWheel(this, new OnOptionsSelectListener() {
            @Override
            public void onOptionsSelect(int options1, int options2, int options3, View v) {


                tvJiabanshijian.setText(item1.get(options1));

            }
        });
        int index = 0;
        if (item1.contains(tvJiabanshijian.getText().toString())) {
            index = item1.indexOf(tvJiabanshijian.getText().toString());
        } else {

        }


        optionsPickerView.setSelectOptions(index);
        optionsPickerView.setPicker(item1);
        optionsPickerView.show();
    }

    @OnClick(R.id.btn_sure)
    public void done() {
       if( StringUtils.isEmpty(tvJiabanshijian.getText())){
           ToastUtil.toast(this,"请输入加班类型");
           return;
        }
        Intent intent = new Intent();
        intent.putExtra("data",tvJiabanshijian.getText().toString());
        setResult(1001, intent);
        finish();
    }
}
